package main;

import java.util.ArrayList;
import java.util.Iterator;

import main.constraint.XDF;

/**
 * A list of xdfs to validate
 * ---------------------------
 * 
 * - This class have list of XDF.
 * - Print to web and application.
 * 
 * @author Maria Adriana 
 */

public class KeysExecution
{
	// Fsas f1 - context, f2 - source, f3 - target
	private ArrayList<XDF> xdfSet = new ArrayList<XDF>();

	public KeysExecution() {}

	public void addKeys(XDF k)
	{
		xdfSet.add(k);
		//System.out.println("XDF" + k);
	}

	/**
	 * This method sorts the ArrayList of keys
	 * by FK references.
	 */
	//public void orderKeys() {
	//	ArrayList<XDF> al1 = new ArrayList<XDF>();
	//	ArrayList<XDF> al2 = new ArrayList<XDF>();
	//	for (Iterator<XDF> i = xdfSet.iterator(); i.hasNext();) {
	//		XDF k = (XDF) i.next();
	//			al2.add(k);
	//	}
	//	al1.addAll(al2);
	//	xdfSet = al1;
	//}

	public ArrayList<XDF> getKeysSet()
	{
		return xdfSet;
	}

	public String toString()
	{
		String str = "List of Constraints to validate:\n\n";
		
		for (Iterator<XDF> i = xdfSet.iterator(); i.hasNext();)
		{
			XDF k = (XDF) i.next();
			str += k.toString() + "\n";
		}
		
		return str;
	}
	
	/**
	 * Retrurn the string of web with XDF
	 * @return string
	 */
	public String toStringWeb()
	{
		String str = "List of Constraints to validate:<br><br>";
		for (Iterator<XDF> i = xdfSet.iterator(); i.hasNext();)
		{
			XDF k = (XDF) i.next();
			str += k.toStringWeb() + "<br>";
		}
		return str;
	}
}
